package com.qingkai.takeawayorders.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import com.qingkai.takeawayorders.category.CategoryModel
import com.qingkai.takeawayorders.category.FoodModel
import com.qingkai.takeawayorders.repository.MainRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class MainViewModel : ViewModel() {
    private val repository = MainRepository()

    //    suspend fun loadCategoryList(): LiveData<MutableList<CategoryModel>> =
//        withContext(Dispatchers.IO) {
//            delay(10000L)
//            return@withContext repository.loadCategoryList()
//        }
    suspend fun loadCategoryList(): LiveData<MutableList<CategoryModel>> =
        repository.loadCategoryList()


    fun loadPopular(): LiveData<MutableList<FoodModel>> {
        return repository.loadPopular()
    }

}